Case has two formats. Simple case function and case search function.--Simple Case functionCase SexWhen ' 1 ' Then ' men 'When ' 2 ' then ' women 'Else ' other ' END--case search functioncase If sex = ' 1 ' Then ' man 'When sex = ' 2 ' Then ' women
Case has two formats. Simple case function and case search function.--Simple Case functionCase SexWhen ' 1 ' Then ' men 'When ' 2 ' then ' women 'Else ' other ' END--case search functioncase If sex = ' 1 ' Then ' man 'When sex = ' 2 ' Then ' women
Conditional statementsdelimiter \\CREATE PROCEDURE proc_if ()BEGIN declare i int default 0; if i = 1 THEN SELECT 1; ELSEIF i = 2 THEN SELECT 2; ELSE SELECT 7; END IF;END\\delimiter ;Looping statementsWhile
Use LOCATE and case when... THEN... ELSE... END in mysql in combination,
In the previous project, you need to write an SQL statement to find out A survey details. Select answer A, Answer B, and answer C... f. The number of people in the answer is
MySQL builds a series of multiple instances. The so-called multi-instance is to build and run multiple MySQL instances on one server. each instance uses different service ports and listens through different sockets. physically, each instance has an
Easy to understand, directly on the example:SELECTCase-------------ifWhen sex= ' 1 ' Then ' Men '-------------sex= ' 1 ', then return value ' Male 'When sex= ' 2 ' Then ' Women '-------------sex= ' 2 ', then the return value ' female 'else 0---------
MySQL builds a series of multiple instances. The so-called multi-instance is to build and run multiple MySQL instances on one server. Each instance uses different service ports and listens through different sockets. Physically, each instance has an
Before the project needs to write a SQL, is to find out a research details, choose a answer, b answer, c answer ... f The answer to how many people each, this SQL is also a great effort to write, it is written down, convenient for later use.Among
Explain:SELECTCase-------------IfWhen the sex= ' 1 ' then ' Male '-------------sex= ' 1 ', the return value ' male 'When the sex= ' 2 ' then ' female '-------------sex= ' 2 ', the return value ' female 'else 0 return ' other '-------------otherEnd---
Explain:SELECTCase-------------IfWhen the sex= ' 1 ' then ' Male '-------------sex= ' 1 ', the return value ' male 'When the sex= ' 2 ' then ' female '-------------sex= ' 2 ', the return value ' female 'else 0 return ' other '-------------otherEnd---
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.